<template>
  <div v-if="Object.keys(commentInfo).length !== 0">
    <div class="title-box">
      <div class="title">
        <span>用户评价</span>
        <span>更多</span>
      </div>
    </div>

    <div class="usr-info">
      <img class="avatar" :src="commentInfo.user.avatar">
      <span class="usr-name">{{commentInfo.user.uname}}</span>

      <p>{{commentInfo.content}}</p>
      <span class="date">{{commentInfo.created | showDate}}</span>
      <span>{{commentInfo.style}}</span>

      <div>
        <img v-for="(item,index) in commentInfo.images" :src="item" :key="index" class="comment-images">
      </div>
    </div>
  </div>
</template>

<script>
  import {formatDate} from "common/utils";

  export default {
    name: "DetailCommentInfo",
    props: {
      commentInfo: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    filters: {
      showDate: function (value) {
        let date = new Date(value*1000);
        return formatDate(date, 'yyyy-MM-dd')
      }
    }
  }
</script>

<style scoped>
  .comment-images{
    width: 70px;
    height: 70px;
    margin-right: 5px;
  }
  .date{
    margin-right: 10px;
  }
  .usr-name{
    color: #777;
  }

  .usr-info{
    padding: 13px;
    font-size: 14px;
    color: #999;
  }

  .usr-info .avatar{
    width: 42px;
    height: 42px;
    border-radius: 50%;
    vertical-align: middle;
  }

  .title-box{
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 18px;
  }
  .title{
    width: 85%;
    font-size: 17px;
    display: flex;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(100,100,100,.1);
  }

</style>